__file__ = 'A05.py'
__author__ = 'Jerry Liu'
__date__ = '2016-04-13'

"""
    问题：你有一个目录，装了很多照片，把它们的尺寸变成都不大于 iPhone5 分辨率的大小。
    常用库：图像处理的库：PIL
           文件路径查找：glob
"""
from PIL import Image
import glob

width = 100
height = 100

def resize(path):
    for png in glob.glob1(path, '*.png'):
        fillName= path + png
        # 新路径
        index = fillName.rfind('.')
        targetpath = fillName[:index] + '_resize' + fillName[index:]
        img = Image.open(fillName)
        # 获取图片尺寸
        x, y = img.size
        newimg = img.resize((width, height))
        newimg.save(targetpath)

if __name__ == '__main__':
    resize('f://image/')
